package com.app.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.app.biz.domain.BizAppRead;
import com.app.biz.dto.BizAppReadDto;
import com.app.biz.service.IBizAppReadService;
import com.app.biz.vo.BizAppReadVo;
import com.app.common.annotation.Log;
import com.app.common.core.controller.BaseController;
import com.app.common.core.domain.AjaxResult;
import com.app.common.core.page.TableDataInfo;
import com.app.common.enums.BusinessType;
import com.app.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * app消息已读（通知公告及安全咨询）Controller
 * 
 *
 */
@RestController
@RequestMapping("/app/read")
public class BizAppReadController extends BaseController
{
    @Autowired
    private IBizAppReadService bizAppReadService;

    /**
     * 查询app消息已读（通知公告及安全咨询）列表
     */
    //@PreAuthorize("@ss.hasPermi('system:read:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizAppReadVo bizAppRead)
    {
        startPage();
        bizAppRead.setUserId(String.valueOf(getUserId()));
        List<BizAppReadDto> list = bizAppReadService.selectBizAppReadList(bizAppRead);
        return getDataTable(list);
    }



    /**
     * 获取app消息已读（通知公告及安全咨询）详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:read:query')")
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(bizAppReadService.selectBizAppReadByBaseId(baseId));
    }



    /**
     * 删除app消息已读（通知公告及安全咨询）
     */
    //@PreAuthorize("@ss.hasPermi('system:read:remove')")
    @Log(title = "app消息已读（通知公告及安全咨询）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(bizAppReadService.deleteBizAppReadByBaseIds(baseIds));
    }

    @Log(title = "app消息设置已读（通知公告及安全咨询）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult read(@RequestBody BizAppRead bizAppRead)
    {
        return toAjax(bizAppReadService.read(bizAppRead));
    }

    @GetMapping(value = "/detail")
    public AjaxResult detail(BizAppRead bizAppRead)
    {
        return success(bizAppReadService.detail(bizAppRead));
    }

    @GetMapping("/unreadCount")
    public AjaxResult unreadCount(BizAppRead bizAppRead)
    {
        bizAppRead.setUserId(String.valueOf(getUserId()));
        return success(bizAppReadService.selectBizAppUnReadCount(bizAppRead));
    }
}
